package com.netease.nie.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.netease.nie.base.utils.CopyUtils;
import com.netease.nie.dao.FeedbackDao;
import com.netease.nie.dao.UserDao;
import com.netease.nie.dto.FeedbackDto;
import com.netease.nie.model.Feedback;
import com.netease.nie.model.User;

@Service
public class FeedbackServiceImpl implements FeedbackService {

	@Autowired
	private FeedbackDao feedbackDao;
	
	@Autowired
	private UserDao userDao;
	
	public int saveFeedbackDto(FeedbackDto feedbackDto) {
		Long userId = feedbackDto.getUserId();
		User user = userDao.queryUserInfoByUserId(userId);
		feedbackDto.setUserId(userId);
		feedbackDto.setUserNickName(user.getNickName());
		feedbackDto.setUserName(user.getUserName());
		Feedback feedback = new Feedback();
		CopyUtils.copy(feedback, feedbackDto);
		long recordTime = System.currentTimeMillis();
		feedback.setRecordTime(recordTime);
		return feedbackDao.saveFeedback(feedback);
	}

}
